package cn.com.generaldata.os.vo;

import lombok.Data;

import org.apache.commons.lang3.StringUtils;

/**
 * 指标汇总查询条件VO.
 */
@Data
public class IndicatorStatQueryVO {

	/** 指标数据来源 */
	private Integer datasource;

	/** 指标大类代码 */
	private String firstIndicatorCodePrefix;

	/** 指标中类代码 */
	private String secondIndicatorCodePrefix;

	/** 统计频率 */
	private int frequency;

	private int year;

	private Integer yearTime;

	private Integer quarter;

	private Integer month;

	/** 省区划代码id */
	private String provinceId;

	/** 市地区id **/
	private String cityId;

	/** 县地区id **/
	private String countyId;

	/** 企业级别 1：直属企业 2 : 所有企业 */
	private Integer unitLevel;

	public String getQueryAreaIdPrefix() {
		String queryAreaidPrefix = "";
		if (StringUtils.isBlank(cityId) && StringUtils.isBlank(countyId)) {
			queryAreaidPrefix = StringUtils.left(provinceId, 2);
		}
		if (StringUtils.isNotBlank(cityId) && StringUtils.isBlank(countyId)) {
			queryAreaidPrefix = StringUtils.left(cityId, 4);
		}
		if (StringUtils.isNotBlank(cityId) && StringUtils.isNotBlank(countyId)) {
			queryAreaidPrefix = StringUtils.left(countyId, 6);
		}
		return queryAreaidPrefix;
	}

	public String getQueryAreaId() {
		String queryAreaid = "";
		if (StringUtils.isBlank(cityId) && StringUtils.isBlank(countyId)) {
			queryAreaid = provinceId;
		}
		if (StringUtils.isNotBlank(cityId) && StringUtils.isBlank(countyId)) {
			queryAreaid = cityId;
		}
		if (StringUtils.isNotBlank(cityId) && StringUtils.isNotBlank(countyId)) {
			queryAreaid = countyId;
		}
		return queryAreaid;
	}

	public String getIndicatorCodePrefix() {
		String indicatorCodePerfix = "";
		if (StringUtils.isNotBlank(secondIndicatorCodePrefix)) {
			indicatorCodePerfix = secondIndicatorCodePrefix;
		}

		if (StringUtils.isBlank(secondIndicatorCodePrefix) && StringUtils.isNotBlank(firstIndicatorCodePrefix)) {
			indicatorCodePerfix = firstIndicatorCodePrefix;
		}
		return indicatorCodePerfix;
	}

}
